﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TimerController : MonoBehaviour
{
    public Text textUI;
    public Text textUIResult;
    private int second;
    private int min;
    private int hour;
    private float count;

    private void OnEnable()
    {
        second = min = hour = 0;
        textUI.text = string.Format("{0:D2}:{1:D2}:{2:D2}", 0, 0, 0);

    }
    private void Update()
    {
        count += Time.deltaTime;
        if (count>1)
        {
            count = 0;
            second++;
            if (second>=60)
            {
                second = 0;
                min++;
            }
            if (min>=60)
            {
                min = 0;
                hour++;
            }
            textUI.text = string.Format("{0:D2}:{1:D2}:{2:D2}", hour, min, second);
        }
    }
}
